var Checker={
	init: function( config ){
		this.config = config;
		console.log('initiated');
		console.log(config);
		this.bindEvents();
		this.fetch_actors();
		
	},

	bindEvents: function(){
		console.log('binded')
		this.config.passwordarea.on('change', this.fetch_actors);
	},


	displayfeedback: function(e,tthis){
		var self = tthis;
		console.log(self);
		console.log(e);
		if(e=='true'){
			console.log('good pass');
			console.log(self.config.errr_msg);
			self.config.errr_msg.addClass('alert-success').removeClass('alert-error');
			self.config.errr_msg.html('<strong>Success!</strong> Heslo pre upload je správne ');
		}else{
			console.log('pass wrong');
			self.config.errr_msg.removeClass('alert-success').addClass('alert-warning');
			self.config.errr_msg.html('<strong>Warning!</strong> Nesprávne heslo ');
		}
	},

	fetch_actors: function(){
		var self = Checker;
		console.log('changed');
		
		$.ajax({
			url:"../auth/check_password",
			type:"POST",
			data: self.config.form.serialize(),
			success: function( results ){
				self.displayfeedback(results, self);
			
			},
		

			});
	},

};

Checker.init({
	passwordarea : $('#heslo'),
	form : $('#new-program_form'),
	errr_msg : $('#pass_err'),
	}
	);